#!/bin/sh

# Author: Zhang Huangbin (michaelbibby <at> gmail.com)

export PROG_NAME='iRedMail'
export PROG_NAME_LOWERCASE='iredmail'
export PROG_VERSION='0.4-stable'

# -----------------
# ---- Generic ----
# -----------------

# Maildir format: mbox, Maildir.
export HOME_MAILBOX='Maildir'

# Use exist Apache, MySQL, PHP: YES, NO.
# Note: You may need to change apache/php related config file path.
# Such as:
#   - MySQL server address and root user acount (conf/mysql).
#   - Path of apache/php config file path (conf/httpd).
export USE_EXIST_AMP='NO'

# Download packages from official yum repository or not, used in 'pkgs/get_all.sh'.
export DOWNLOAD_PKGS='YES'

# For distribute deployment.
export IMAP_SERVER='127.0.0.1'
export SMTP_SERVER='127.0.0.1'

if [ X"${YUM}" == X"" ]; then
    export YUM='yum -d 2'
else
    export YUM=${YUM}
fi

# vmail user. uid and gid should be export after user added. Reference:
# functions/user_vmail.sh
export VMAIL_USER_NAME='vmail'
export VMAIL_GROUP_NAME='vmail'
export VMAIL_ADMIN_USER_NAME="${VMAIL_USER_NAME}admin"

# Default virtual domain admin name without domain name (@example.com).
export DOMAIN_ADMIN_NAME='postmaster'

# SPF.
# Either 'pypolicyd-spf' or 'perl-Mail-SPF'
# pypolicyd-spf is *NOT* recommended.
export SPF_PROGRAM='perl-Mail-SPF'

# Directory /etc/sysconfig/ on RHEL/CentOS.
export ETC_SYSCONFIG_DIR='/etc/sysconfig'

# Iptables rule file.
export IPTABLES_CONFIG="${ETC_SYSCONFIG_DIR}/iptables"

# Hostname.
export HOSTNAME="$(grep '^HOSTNAME' ${ETC_SYSCONFIG_DIR}/network | awk -F'=' '{print $2}' | sed 's/"//g' | sed "s/'//g")"

# SSL/TLS support.
export SSL_FILE_DIR="/etc/pki/${PROG_NAME}"
export SSL_CERT_FILE="${SSL_FILE_DIR}/SSL_Cert.pem"
export SSL_KEY_FILE="${SSL_FILE_DIR}/SSL_Key.pem"
export TLS_COUNTRY='CN'
export TLS_STATE='GuangDong'
export TLS_CITY='ShenZhen'
export TLS_COMPANY="${HOSTNAME}"
export TLS_DEPARTMENT='IT'
export TLS_HOSTNAME="${HOSTNAME}"
export TLS_ADMIN="root@${HOSTNAME}"

# ----------------------------------
# You do *NOT* need to modify them.
# ----------------------------------
export DATE="$(/bin/date +%Y.%m.%d_%H.%M.%S)"

# Tools.
export CONFIG_VIA_DIALOG="${DIALOG_DIR}/config_via_dialog.sh"
# Note: config file will be sourced in file 'conf/functions', function 'check_env()'.
export CONFIG_FILE="${ROOTDIR}/config"
export TIP_FILE="${ROOTDIR}/${PROG_NAME}.tips"
export STATUS_FILE="${ROOTDIR}/.${PROG_NAME}.installation.status"

# Output flag.
export INFO_FLAG="< INFO >"
export QUESTION_FLAG="< Question >"
export BACKUP_FLAG="< Backup >"

export CONF_MSG="#
# File generated by ${PROG_NAME} (${DATE}) which stands for:
# Mail Server Solution for Red Hat(R) Enterprise Linux series.
#
# Version:  ${PROG_VERSION}
# Project:  http://code.google.com/p/iredmail/
#
# If you deploy ${PROG_VERSION} in product environment, we suggest
# you public your information in 'Success Stories' page to help us
# generalization ${PROG_VERSION}, and you can join iredmailsupport@
# mail list for further technique support, such as bug/issue fix,
# event response, software update, etc.
#
# Success Stories:
#   http://www.iredmail.org/wiki/index.php/IRedMail_Success_Stories
#
# Mail list:
#   http://groups.google.com/group/iredmailsupport/
#
# Genernal Forum:
#   * International: http://groups.google.com/group/iredmail/
#   * Chinese only: http://www.iredmail.org/bbs/
#
"

# For perl and run-time locale setting.
export LC_ALL=C

# TERM.
if [ X"${TERM}" == X"xterm" ]; then
    export TERM='xterm'
else
    export TERM='pcconsole'
fi

# Arch.
export ARCH="$(uname -i)"
export KERNEL_NAME="$(uname -s)"

# Crontab related.
export CRON_SPOOL_DIR="/var/spool/cron"

# Logrotate configuration directory.
export LOGROTATE_DIR='/etc/logrotate.d'

# Yum repository related.
export YUM_REPOS_DIR='/etc/yum.repos.d'
export LOCAL_REPO_NAME="${PROG_NAME}"
export LOCAL_REPO_FILE="${YUM_REPOS_DIR}/${LOCAL_REPO_NAME}.repo"
export YUM_UPDATE_REPO='http://www.iredmail.org/yum/rpms/5/'

# Genrate a random string.
# Usage:
#   str="$(${RANDOM_STRING})"
export RANDOM_STRING='eval </dev/urandom tr -dc A-Za-z0-9| (head -c $1 > /dev/null 2>&1 || head -c 30)'

# Syslog config file.
export SYSLOG_CONF='/etc/syslog.conf'

# Make some command operating system independent.
if [ X"${KERNEL_NAME}" == X"Linux" -a -f /etc/redhat-release ]; then
    # RHEL/CentOS
    export LIST_FILES_IN_PKG='rpm -ql'
else
    :
fi

if [ X"${KERNEL_NAME}" == X"Linux" -a -f /etc/redhat-release ]; then
    # RHEL/CentOS
    export LIST_ALL_PKGS='rpm -qa'
else
    :
fi
